﻿using H2.NET.Web.Management.Config.Service;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace H2.NET.Web.Pages.SMD
{
    public partial class uc_region : System.Web.UI.UserControl
    {
        public string regin
        {
            get
            {
                return ddl_region.SelectedValue;
            }
            set
            {
                ddl_region.SelectedValue = value;
            }
        }

        public string province
        {
            get
            {
                return ddl_province.SelectedValue;
            }
            set
            {
                ddl_province.SelectedValue = value;
            }
        }

        public string city
        {
            get
            {
                return ddl_city.SelectedValue;
            }
            set
            {
                ddl_city.SelectedValue = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var configService = new ConfigService();

                var where = "ParentId = (select configid from t_smd_Config where code='M_MDQY') order by seq";

                var dt_region = configService.GetList(where).Tables[0];
                ddl_region.AppendDataBoundItems = true;
                ddl_region.Items.Add(new ListItem("==请选择==", ""));
                foreach (DataRow row in dt_region.Rows)
                {
                    ddl_region.Items.Add(new ListItem(row["Name"].ToString(), row["Name"].ToString()));
                }
            }
        }
    }
}